package com.ruoyi.web.controller.common;

import com.github.abel533.echarts.Option;
import com.github.abel533.echarts.axis.CategoryAxis;
import com.github.abel533.echarts.axis.ValueAxis;
import com.github.abel533.echarts.code.AxisType;
import com.github.abel533.echarts.series.Bar;
import com.ruoyi.common.core.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/finance/budgetChart")
public class TestController extends BaseController {

    @RequestMapping("/haha")
    public String haha() {
        return "/testEcharts";
    }

    /*
     * 获取柱状图 json数据
     * */
    @GetMapping("/getOption")
    @ResponseBody
    public Option getOption()
    {
        Option option = new Option();
        option.tooltip().show(true);
        option.legend().data("销量");

        ValueAxis valueAxis = new ValueAxis();
        valueAxis.type(AxisType.category);
        valueAxis.data("衬衫","羊毛衫","雪纺衫","裤子","高更鞋","袜子");
        option.xAxis(valueAxis);

        CategoryAxis categoryAxis = new CategoryAxis();
        categoryAxis.type(AxisType.value);
        option.yAxis(categoryAxis);

        Bar bar = new Bar();
        bar.name("销量").data(5, 20, 40, 10 , 10, 20);

        option.series(bar);

        return option;
    }

}
